



//input.js
Page({
  data: {
    item1: ["金额", "price"],
    item2: ["分类", "classify"],
    item3: ["时间", "date"],
    item4: ["备注", "remark"],
    item1_placeholder: "0",
    item4_placeholder: "钱去哪儿了",
    boolean1: true,
    boolean2: true,
    default_value: "",
    array: ['食品', '衣着', '居住', '家庭设备用品及服务', '医疗保健', '交通和通信', '教育文化娱乐服务', '其他商品和服务']
  },
  bindPickerChange: function (e) {
    console.log('picker发送选择改变，携带值为', e.detail.value)
    this.setData({
      index: e.detail.value,
      boolean1: false
    })
    console.log('bol -> ' + this.data.boolean1)
  },
  bindDateChange: function (e) {
    console.log('picker发送选择改变，携带值为', e.detail.value)
    this.setData({
      date: e.detail.value,
      boolean2: false
    })
  },
  formSubmit: function (e) {
    console.log('form发生了submit事件，携带数据为：', e.detail.value)

    var s_data = e.detail.value
    console.log('s_key' + s_data)
    var s_keys = s_data["date"].split("-")
    var s_key = s_keys[0] + "-" + s_keys[1]



    console.log('s_key = ' + s_key)
    console.log('classify = ' + s_data["classify"])
    console.log('date = ' + s_data["date"])
    console.log('remark = ' + s_data["remark"])

    wx.setStorage({
      key: s_key,
      data: {
        "price": s_data["price"],
        "classify": s_data["classify"],
        "date": s_data["date"],
        "remark": s_data["remark"],
      }
    })


    wx.showToast({
      title: '保存成功',
      icon: 'success',
      duration: 2000,
    })
    this.formReset(e)
    this.setData({
      default_value: '',
      index: '',
      date: ''
    })

  },
  formReset: function (e) {
    console.log('form发生了reset事件')
    this.setData({
      boolean1: true,
      boolean2: true
    })
  }
})